3.249 \(\int \frac{(a+a \sin (e+f x)) (A+B \sin (e+f x))}{(c+d \sin (e+f x))^2} \, dx\)

Optimal. Leaf size=124 \[ \frac{2 a \left (d^2 (A+B) (c-d)-B c \left (c^2-d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2 f \left (c^2-d^2\right )^{3/2}}+\frac{a (B c-A d) \cos (e+f x)}{d f (c+d) (c+d \sin (e+f x))}+\frac{a B x}{d^2} \]

[Out]

(a*B*x)/d^2 + (2*a*((A + B)*(c - d)*d^2 - B*c*(c^2 - d^2))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(
d^2*(c^2 - d^2)^(3/2)*f) + (a*(B*c - A*d)*Cos[e + f*x])/(d*(c + d)*f*(c + d*Sin[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.325147, antiderivative size = 124, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 33, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.182, Rules used = {2968, 3021, 2735, 2660, 618, 204} \[ \frac{2 a \left (d^2 (A+B) (c-d)-B c \left (c^2-d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2 f \left (c^2-d^2\right )^{3/2}}+\frac{a (B c-A d) \cos (e+f x)}{d f (c+d) (c+d \sin (e+f x))}+\frac{a B x}{d^2} \]

Antiderivative was successfully verified.

[In]

Int[((a + a*Sin[e + f*x])*(A + B*Sin[e + f*x]))/(c + d*Sin[e + f*x])^2,x]

[Out]

(a*B*x)/d^2 + (2*a*((A + B)*(c - d)*d^2 - B*c*(c^2 - d^2))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(
d^2*(c^2 - d^2)^(3/2)*f) + (a*(B*c - A*d)*Cos[e + f*x])/(d*(c + d)*f*(c + d*Sin[e + f*x]))

Rule 2968

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*sin[(
e_.) + (f_.)*(x_)]), x_Symbol] :> Int[(a + b*Sin[e + f*x])^m*(A*c + (B*c + A*d)*Sin[e + f*x] + B*d*Sin[e + f*x
]^2), x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] && NeQ[b*c - a*d, 0]

Rule 3021

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)] + (C_.)*sin[(e_.) + (f
_.)*(x_)]^2), x_Symbol] :> -Simp[((A*b^2 - a*b*B + a^2*C)*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1))/(b*f*(m +
 1)*(a^2 - b^2)), x] + Dist[1/(b*(m + 1)*(a^2 - b^2)), Int[(a + b*Sin[e + f*x])^(m + 1)*Simp[b*(a*A - b*B + a*
C)*(m + 1) - (A*b^2 - a*b*B + a^2*C + b*(A*b - a*B + b*C)*(m + 1))*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, e,
 f, A, B, C}, x] && LtQ[m, -1] && NeQ[a^2 - b^2, 0]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{(a+a \sin (e+f x)) (A+B \sin (e+f x))}{(c+d \sin (e+f x))^2} \, dx &=\int \frac{a A+(a A+a B) \sin (e+f x)+a B \sin ^2(e+f x)}{(c+d \sin (e+f x))^2} \, dx\\ &=\frac{a (B c-A d) \cos (e+f x)}{d (c+d) f (c+d \sin (e+f x))}-\frac{\int \frac{-a (A+B) (c-d) d-a B \left (c^2-d^2\right ) \sin (e+f x)}{c+d \sin (e+f x)} \, dx}{d \left (c^2-d^2\right )}\\ &=\frac{a B x}{d^2}+\frac{a (B c-A d) \cos (e+f x)}{d (c+d) f (c+d \sin (e+f x))}+\frac{\left (a \left (A d^2-B \left (c^2+c d-d^2\right )\right )\right ) \int \frac{1}{c+d \sin (e+f x)} \, dx}{d^2 (c+d)}\\ &=\frac{a B x}{d^2}+\frac{a (B c-A d) \cos (e+f x)}{d (c+d) f (c+d \sin (e+f x))}+\frac{\left (2 a \left (A d^2-B \left (c^2+c d-d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+2 d x+c x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^2 (c+d) f}\\ &=\frac{a B x}{d^2}+\frac{a (B c-A d) \cos (e+f x)}{d (c+d) f (c+d \sin (e+f x))}-\frac{\left (4 a \left (A d^2-B \left (c^2+c d-d^2\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{-4 \left (c^2-d^2\right )-x^2} \, dx,x,2 d+2 c \tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^2 (c+d) f}\\ &=\frac{a B x}{d^2}+\frac{2 a \left (A d^2-B \left (c^2+c d-d^2\right )\right ) \tan ^{-1}\left (\frac{d+c \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c^2-d^2}}\right )}{d^2 (c+d) \sqrt{c^2-d^2} f}+\frac{a (B c-A d) \cos (e+f x)}{d (c+d) f (c+d \sin (e+f x))}\\ \end{align*}

Mathematica [C]  time = 1.31534, size = 217, normalized size = 1.75 \[ \frac{a (\sin (e+f x)+1) \left (\frac{2 (\cos (e)-i \sin (e)) \left (A d^2-B \left (c^2+c d-d^2\right )\right ) \tan ^{-1}\left (\frac{(\cos (e)-i \sin (e)) \sec \left (\frac{f x}{2}\right ) \left (c \sin \left (\frac{f x}{2}\right )+d \cos \left (e+\frac{f x}{2}\right )\right )}{\sqrt{c^2-d^2} \sqrt{(\cos (e)-i \sin (e))^2}}\right )}{f (c+d) \sqrt{c^2-d^2} \sqrt{(\cos (e)-i \sin (e))^2}}+\frac{\csc (e) (A d-B c) (c \cos (e)+d \sin (f x))}{f (c+d) (c+d \sin (e+f x))}+B x\right )}{d^2 \left (\sin \left (\frac{1}{2} (e+f x)\right )+\cos \left (\frac{1}{2} (e+f x)\right )\right )^2} \]

Antiderivative was successfully verified.

[In]

Integrate[((a + a*Sin[e + f*x])*(A + B*Sin[e + f*x]))/(c + d*Sin[e + f*x])^2,x]

[Out]

(a*(1 + Sin[e + f*x])*(B*x + (2*(A*d^2 - B*(c^2 + c*d - d^2))*ArcTan[(Sec[(f*x)/2]*(Cos[e] - I*Sin[e])*(d*Cos[
e + (f*x)/2] + c*Sin[(f*x)/2]))/(Sqrt[c^2 - d^2]*Sqrt[(Cos[e] - I*Sin[e])^2])]*(Cos[e] - I*Sin[e]))/((c + d)*S
qrt[c^2 - d^2]*f*Sqrt[(Cos[e] - I*Sin[e])^2]) + ((-(B*c) + A*d)*Csc[e]*(c*Cos[e] + d*Sin[f*x]))/((c + d)*f*(c
+ d*Sin[e + f*x]))))/(d^2*(Cos[(e + f*x)/2] + Sin[(e + f*x)/2])^2)

________________________________________________________________________________________

Maple [B]  time = 0.141, size = 434, normalized size = 3.5 \begin{align*} -2\,{\frac{da\tan \left ( 1/2\,fx+e/2 \right ) A}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ( c+d \right ) c}}+2\,{\frac{a\tan \left ( 1/2\,fx+e/2 \right ) B}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ( c+d \right ) }}-2\,{\frac{Aa}{f \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ( c+d \right ) }}+2\,{\frac{Bac}{df \left ( c \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) ^{2}+2\,\tan \left ( 1/2\,fx+e/2 \right ) d+c \right ) \left ( c+d \right ) }}+2\,{\frac{Aa}{f \left ( c+d \right ) \sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }-2\,{\frac{Ba{c}^{2}}{f{d}^{2} \left ( c+d \right ) \sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }-2\,{\frac{Bac}{df \left ( c+d \right ) \sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+2\,{\frac{Ba}{f \left ( c+d \right ) \sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( 1/2\,fx+e/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+2\,{\frac{Ba\arctan \left ( \tan \left ( 1/2\,fx+e/2 \right ) \right ) }{f{d}^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+a*sin(f*x+e))*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x)

[Out]

-2/f*a*d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c+d)/c*tan(1/2*f*x+1/2*e)*A+2/f*a/(c*tan(1/2*f*x+1
/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c+d)*tan(1/2*f*x+1/2*e)*B-2/f*a/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e
)*d+c)/(c+d)*A+2/f*a/d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c+d)*B*c+2/f*a/(c+d)/(c^2-d^2)^(1/2)
*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*A-2/f*a/d^2/(c+d)/(c^2-d^2)^(1/2)*arctan(1/2*(2*c*ta
n(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*B*c^2-2/f*a/d/(c+d)/(c^2-d^2)^(1/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+
2*d)/(c^2-d^2)^(1/2))*B*c+2/f*a/(c+d)/(c^2-d^2)^(1/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))
*B+2/f*a*B/d^2*arctan(tan(1/2*f*x+1/2*e))

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+a*sin(f*x+e))*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 2.25826, size = 1416, normalized size = 11.42 \begin{align*} \left [\frac{2 \,{\left (B a c^{3} d + B a c^{2} d^{2} - B a c d^{3} - B a d^{4}\right )} f x \sin \left (f x + e\right ) + 2 \,{\left (B a c^{4} + B a c^{3} d - B a c^{2} d^{2} - B a c d^{3}\right )} f x +{\left (B a c^{3} + B a c^{2} d -{\left (A + B\right )} a c d^{2} +{\left (B a c^{2} d + B a c d^{2} -{\left (A + B\right )} a d^{3}\right )} \sin \left (f x + e\right )\right )} \sqrt{-c^{2} + d^{2}} \log \left (\frac{{\left (2 \, c^{2} - d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2} + 2 \,{\left (c \cos \left (f x + e\right ) \sin \left (f x + e\right ) + d \cos \left (f x + e\right )\right )} \sqrt{-c^{2} + d^{2}}}{d^{2} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2}}\right ) + 2 \,{\left (B a c^{3} d - A a c^{2} d^{2} - B a c d^{3} + A a d^{4}\right )} \cos \left (f x + e\right )}{2 \,{\left ({\left (c^{3} d^{3} + c^{2} d^{4} - c d^{5} - d^{6}\right )} f \sin \left (f x + e\right ) +{\left (c^{4} d^{2} + c^{3} d^{3} - c^{2} d^{4} - c d^{5}\right )} f\right )}}, \frac{{\left (B a c^{3} d + B a c^{2} d^{2} - B a c d^{3} - B a d^{4}\right )} f x \sin \left (f x + e\right ) +{\left (B a c^{4} + B a c^{3} d - B a c^{2} d^{2} - B a c d^{3}\right )} f x +{\left (B a c^{3} + B a c^{2} d -{\left (A + B\right )} a c d^{2} +{\left (B a c^{2} d + B a c d^{2} -{\left (A + B\right )} a d^{3}\right )} \sin \left (f x + e\right )\right )} \sqrt{c^{2} - d^{2}} \arctan \left (-\frac{c \sin \left (f x + e\right ) + d}{\sqrt{c^{2} - d^{2}} \cos \left (f x + e\right )}\right ) +{\left (B a c^{3} d - A a c^{2} d^{2} - B a c d^{3} + A a d^{4}\right )} \cos \left (f x + e\right )}{{\left (c^{3} d^{3} + c^{2} d^{4} - c d^{5} - d^{6}\right )} f \sin \left (f x + e\right ) +{\left (c^{4} d^{2} + c^{3} d^{3} - c^{2} d^{4} - c d^{5}\right )} f}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+a*sin(f*x+e))*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="fricas")

[Out]

[1/2*(2*(B*a*c^3*d + B*a*c^2*d^2 - B*a*c*d^3 - B*a*d^4)*f*x*sin(f*x + e) + 2*(B*a*c^4 + B*a*c^3*d - B*a*c^2*d^
2 - B*a*c*d^3)*f*x + (B*a*c^3 + B*a*c^2*d - (A + B)*a*c*d^2 + (B*a*c^2*d + B*a*c*d^2 - (A + B)*a*d^3)*sin(f*x
+ e))*sqrt(-c^2 + d^2)*log(((2*c^2 - d^2)*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2 + 2*(c*cos(f*x + e)*
sin(f*x + e) + d*cos(f*x + e))*sqrt(-c^2 + d^2))/(d^2*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2)) + 2*(B
*a*c^3*d - A*a*c^2*d^2 - B*a*c*d^3 + A*a*d^4)*cos(f*x + e))/((c^3*d^3 + c^2*d^4 - c*d^5 - d^6)*f*sin(f*x + e)
+ (c^4*d^2 + c^3*d^3 - c^2*d^4 - c*d^5)*f), ((B*a*c^3*d + B*a*c^2*d^2 - B*a*c*d^3 - B*a*d^4)*f*x*sin(f*x + e)
+ (B*a*c^4 + B*a*c^3*d - B*a*c^2*d^2 - B*a*c*d^3)*f*x + (B*a*c^3 + B*a*c^2*d - (A + B)*a*c*d^2 + (B*a*c^2*d +
B*a*c*d^2 - (A + B)*a*d^3)*sin(f*x + e))*sqrt(c^2 - d^2)*arctan(-(c*sin(f*x + e) + d)/(sqrt(c^2 - d^2)*cos(f*x
 + e))) + (B*a*c^3*d - A*a*c^2*d^2 - B*a*c*d^3 + A*a*d^4)*cos(f*x + e))/((c^3*d^3 + c^2*d^4 - c*d^5 - d^6)*f*s
in(f*x + e) + (c^4*d^2 + c^3*d^3 - c^2*d^4 - c*d^5)*f)]

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+a*sin(f*x+e))*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))**2,x)

[Out]

Timed out

________________________________________________________________________________________

Giac [A]  time = 1.27083, size = 275, normalized size = 2.22 \begin{align*} \frac{\frac{{\left (f x + e\right )} B a}{d^{2}} - \frac{2 \,{\left (B a c^{2} + B a c d - A a d^{2} - B a d^{2}\right )}{\left (\pi \left \lfloor \frac{f x + e}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (c\right ) + \arctan \left (\frac{c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + d}{\sqrt{c^{2} - d^{2}}}\right )\right )}}{{\left (c d^{2} + d^{3}\right )} \sqrt{c^{2} - d^{2}}} + \frac{2 \,{\left (B a c d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) - A a d^{2} \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + B a c^{2} - A a c d\right )}}{{\left (c^{2} d + c d^{2}\right )}{\left (c \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right )^{2} + 2 \, d \tan \left (\frac{1}{2} \, f x + \frac{1}{2} \, e\right ) + c\right )}}}{f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+a*sin(f*x+e))*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="giac")

[Out]

((f*x + e)*B*a/d^2 - 2*(B*a*c^2 + B*a*c*d - A*a*d^2 - B*a*d^2)*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn(c) + arct
an((c*tan(1/2*f*x + 1/2*e) + d)/sqrt(c^2 - d^2)))/((c*d^2 + d^3)*sqrt(c^2 - d^2)) + 2*(B*a*c*d*tan(1/2*f*x + 1
/2*e) - A*a*d^2*tan(1/2*f*x + 1/2*e) + B*a*c^2 - A*a*c*d)/((c^2*d + c*d^2)*(c*tan(1/2*f*x + 1/2*e)^2 + 2*d*tan
(1/2*f*x + 1/2*e) + c)))/f